package com.test.aliai;

import com.alibaba.cloudapi.sdk.constant.SdkConstant;
import com.alibaba.cloudapi.sdk.enums.HttpMethod;
import com.alibaba.cloudapi.sdk.model.ApiResponse;
import com.alibaba.cloudapi.sdk.model.HttpClientBuilderParams;
import com.test.utils.JsonUtil;

import java.util.HashMap;
import java.util.Map;

public class BankCardInfoClient extends AbstractAliApi {

    private final static String HOST = "cnaps.market.alicloudapi.com";

    private final static String PATH = "/lianzhuo/querybankaps";

    public BankCardInfoClient(HttpClientBuilderParams params) {
        super(params);
    }

    @Override
    public String getHost() {
        return HOST;
    }

    @Override
    public String getPath() {
        return PATH;
    }

    @Override
    public HttpMethod getHttpMethod() {
        return HttpMethod.GET;
    }

    public static void main(String[] args) {
        HttpClientBuilderParams param = new HttpClientBuilderParams();
        param.setAppKey(Const.ALI_ACCESS_KEY_ID);
        param.setAppSecret(Const.ALI_SECRET);
        BankCardInfoClient client = new BankCardInfoClient(param);
        Map<String, Object> body = new HashMap<>();
        body.put("card", "6231080360070445");
        String jsonStr = JsonUtil.toJson(body);
        ApiResponse response = client.syncReq(jsonStr.getBytes(SdkConstant.CLOUDAPI_ENCODING));
        String resultStr = new String(response.getBody() , SdkConstant.CLOUDAPI_ENCODING);
        System.out.println(resultStr);
    }
}
